From: Ian Campbell Date: Mon, 18 Oct 2010 16:37:31 +0000 (+0100) Subject: libxc: simplify performance counters API X-Git-Tag: archive/raspbian/4.8.0-1+rpi1~1^2~11384 X-Git-Url: https://dgit.raspbian.org/%22http:/www.example.com/cgi/%22https:/%22bookmarks://%22Dat/%22http:/www.example.com/cgi/%22https:/%22bookmarks:/%22Dat?a=commitdiff_plain;h=656ba9748a4af226415bf77039a20a1948444445;p=xen.git libxc: simplify performance counters API Current function has heavily overloaded semantics for the various arguments. Separate out into more specific functions. Signed-off-by: Ian Campbell Signed-off-by: Ian Jackson --- diff --git a/tools/libxc/xc_misc.c b/tools/libxc/xc_misc.c index 47acdb2fb8..a64a633e29 100644 --- a/tools/libxc/xc_misc.c +++ b/tools/libxc/xc_misc.c @@ -167,20 +167,29 @@ int xc_mca_op(xc_interface *xch, struct xen_mc *mc) } #endif -int xc_perfc_control(xc_interface *xch, - uint32_t opcode, - xc_perfc_desc_t *desc, - xc_perfc_val_t *val, - int *nbr_desc, - int *nbr_val) +int xc_perfc_reset(xc_interface *xch) +{ + DECLARE_SYSCTL; + + sysctl.cmd = XEN_SYSCTL_perfc_op; + sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_reset; + set_xen_guest_handle(sysctl.u.perfc_op.desc, NULL); + set_xen_guest_handle(sysctl.u.perfc_op.val, NULL); + + return do_sysctl(xch, &sysctl); +} + +int xc_perfc_query_number(xc_interface *xch, + int *nbr_desc, + int *nbr_val) { int rc; DECLARE_SYSCTL; sysctl.cmd = XEN_SYSCTL_perfc_op; - sysctl.u.perfc_op.cmd = opcode; - set_xen_guest_handle(sysctl.u.perfc_op.desc, desc); - set_xen_guest_handle(sysctl.u.perfc_op.val, val); + sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query; + set_xen_guest_handle(sysctl.u.perfc_op.desc, NULL); + set_xen_guest_handle(sysctl.u.perfc_op.val, NULL); rc = do_sysctl(xch, &sysctl); @@ -192,6 +201,20 @@ int xc_perfc_control(xc_interface *xch, return rc; } +int xc_perfc_query(xc_interface *xch, + xc_perfc_desc_t *desc, + xc_perfc_val_t *val) +{ + DECLARE_SYSCTL; + + sysctl.cmd = XEN_SYSCTL_perfc_op; + sysctl.u.perfc_op.cmd = XEN_SYSCTL_PERFCOP_query; + set_xen_guest_handle(sysctl.u.perfc_op.desc, desc); + set_xen_guest_handle(sysctl.u.perfc_op.val, val); + + return do_sysctl(xch, &sysctl); +} + int xc_lockprof_control(xc_interface *xch, uint32_t opcode, uint32_t *n_elems, diff --git a/tools/libxc/xenctrl.h b/tools/libxc/xenctrl.h index e45861f2b3..c004cbc660 100644 --- a/tools/libxc/xenctrl.h +++ b/tools/libxc/xenctrl.h @@ -887,14 +887,15 @@ unsigned long xc_make_page_below_4G(xc_interface *xch, uint32_t domid, typedef xen_sysctl_perfc_desc_t xc_perfc_desc_t; typedef xen_sysctl_perfc_val_t xc_perfc_val_t; +int xc_perfc_reset(xc_interface *xch); +int xc_perfc_query_number(xc_interface *xch, + int *nbr_desc, + int *nbr_val); /* IMPORTANT: The caller is responsible for mlock()'ing the @desc and @val arrays. */ -int xc_perfc_control(xc_interface *xch, - uint32_t op, - xc_perfc_desc_t *desc, - xc_perfc_val_t *val, - int *nbr_desc, - int *nbr_val); +int xc_perfc_query(xc_interface *xch, + xc_perfc_desc_t *desc, + xc_perfc_val_t *val); typedef xen_sysctl_lockprof_data_t xc_lockprof_data_t; /* IMPORTANT: The caller is responsible for mlock()'ing the @data array. */ diff --git a/tools/misc/xenperf.c b/tools/misc/xenperf.c index 3730efdbb7..583abc1f82 100644 --- a/tools/misc/xenperf.c +++ b/tools/misc/xenperf.c @@ -137,8 +137,7 @@ int main(int argc, char *argv[]) if ( reset ) { - if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_reset, - NULL, NULL, NULL, NULL) != 0 ) + if ( xc_perfc_reset(xc_handle) != 0 ) { fprintf(stderr, "Error reseting performance counters: %d (%s)\n", errno, strerror(errno)); @@ -148,8 +147,7 @@ int main(int argc, char *argv[]) return 0; } - if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query, - NULL, NULL, &num_desc, &num_val) != 0 ) + if ( xc_perfc_query_number(xc_handle, &num_desc, &num_val) != 0 ) { fprintf(stderr, "Error getting number of perf counters: %d (%s)\n", errno, strerror(errno)); @@ -169,8 +167,7 @@ int main(int argc, char *argv[]) exit(-1); } - if ( xc_perfc_control(xc_handle, XEN_SYSCTL_PERFCOP_query, - pcd, pcv, NULL, NULL) != 0 ) + if ( xc_perfc_query(xc_handle, pcd, pcv) != 0 ) { fprintf(stderr, "Error getting perf counter: %d (%s)\n", errno, strerror(errno));